<layout name="page" />
<block name="js">
	<div id="myModal" class="hidden">
		<div class="popup-frame">
			<div class="popup-header">
				<div class="pull-left">
					<h1>找回密码</h1>
				</div>
				<div class="pull-right">
					<a id="btn_close" class="btn btn-return">关闭</a>
				</div>
			</div>
			<div class="popup-body">
				<div class="popup-body-scroll">
					<div class="popup-content">
						<form id="form_password" method="post" action="" >
							<input type="hidden" name="state"id="state"value="ture"/>
							<input type="hidden" name="ajax" id="ajax" value="1">
							
								<label class="input-label" ></label>
								
									<a onclick="send_sms_verify(this)">发送验证码到手机</a>
								</div>
							</div>
							
								<label class="input-label" for="list_rows">验证码：</label>
								<input class="input col-38" type="text" name="verify_no" id="verify_no" value=""  >
							</div>
							
								<label class="input-label" for="list_rows">新密码：</label>
								<input class="input col-38" type="password" name="password" id="password" value=""  >
							</div>
							
								<div class="input-block" id="msg">
									&nbsp;
								</div>
							</div>
							
								<label class="input-label" for="name"></label>
								
									<a id="btn_save" class="btn" >确定</a>
									
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>

	<script type="text/javascript">
		layui.use(['global'], function() {
			var $ = layui.jquery;

			$('#myModal').removeClass('hidden');
			var index = layer.open({
				type : 1,
				title : false,
				area : [560 + 'px', 460 + 'px'],
				shade : 0.6,
				closeBtn : 0,
				shadeClose : false,
				scrollbar : false,
				content : $('#myModal')
			});
			if (is_mobile()) {
				layer.full(index);
			}



			//关闭iframe
			$('#btn_close').click(function() {
				$('#myModal').addClass('hidden');
				layer.close(index);
			});
			$(document).ready(function() {
				$("#password").keydown(function() {
					s = $(this).val();
					t = check_password(s);
					if (t == 0) {
						$("#msg").html("密码过短");
						$("#msg").css("color", "red");
					}
					if (t == 1) {
						$("#msg").html("密码强度差");
						$("#msg").css("color", "red");
					}
					if (t == 2) {
						$("#msg").html("密码强度良好");
						$("#msg").css("color", "blue");
					}
					if (t == 3) {
						$("#msg").html("密码强度高");
						$("#msg").css("color", "blue");
					}
				});

				$("#confirm_password").keyup(function() {
					new_pwd = $("#password").val();
					confirm_pwd = $(this).val();
					if (new_pwd != confirm_pwd) {
						$("#msg").html("密码不一致");
						$("#msg").css("color", "red");
					} else {
						$("#msg").html("密码一致");
						$("#msg").css("color", "blue");
						$("#status").val("true");
					}
				});
			});
			$('#btn_save').on('click', function() {
				var vars = $("#form_password").serialize();
				send_ajax("{:url('find_pwd')}", vars, function(data) {
					if (data.status) {
						layer.msg(data.info, function() {
							window.open("{:url('enter_pwd')}", "_self");
						});
					} else {
						layui.msg(data.info);
					}
				});
			});
		});
		var countdown = 60;
		var is_send = false;
		function send_sms_verify(obj) {
			if (is_send) {
				return false;
			}
			vars = 'emp_no=' + $("#emp_no").val();
			send_ajax("{:url('send_sms_verify')}", vars, function(data) {
				if (data.status) {
					is_send = true;
					$int = setInterval(function() {
						obj.setAttribute("disabled", true);
						obj.text = "已发送,请等待(" + countdown + ")";
						countdown--;
						if (countdown == 0) {
							obj.text = "发送验证码到手机";
							clearInterval($int);
							countdown = 60;
							is_send = false;
						}
					}, 1000);
				} else {
					layer.msg(data.info);
					return false;
				}
			});
		}

		function check_password(s) {
			if (s.length < 4) {
				return 0;
			}
			var ls = 0;
			if (s.match(/[a-z]/ig)) {
				ls++;
			}
			if (s.match(/[0-9]/ig)) {
				ls++;
			}
			if (s.match(/(.[^a-z0-9])/ig)) {
				ls++;
			}
			if (s.length < 6 && ls > 0) {
				ls--;
			}
			return ls;
		}

		


	
	</script>
</block>
